package com.gkzf.ai.module.crm.service.creditReport;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gkzf.ai.module.crm.dal.dataobject.creditReport.CreditReportLoanOverdueDO;
import com.gkzf.ai.module.crm.dal.mysql.creditReport.CreditReportLoanOverdueMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * 征信报告 逾期信息明细 Service 实现类
 *
 * @author 国科智飞
 */
@Service
@Validated
public class CreditReportLoanOverdueServiceImpl implements CreditReportLoanOverdueService {

    @Resource
    private CreditReportLoanOverdueMapper creditReportLoanOverdueMapper;

    @Override
    public void createCreditReportLoanOverdue(List<CreditReportLoanOverdueDO> creditReportLoanOverdueDO,Long creditReportDetailsId,String creator) {
        creditReportLoanOverdueDO.forEach(item -> {
            item.setCreditReportDetailsId(creditReportDetailsId);
            item.setCreator(creator);
            item.setUpdater(creator);
        });
        // 插入
        creditReportLoanOverdueMapper.insert(creditReportLoanOverdueDO);
    }

    @Override
    public void updateCreditReportLoanOverdue(List<CreditReportLoanOverdueDO> creditReportLoanOverdueDO) {
        // 更新
        creditReportLoanOverdueMapper.updateById(creditReportLoanOverdueDO);
    }

    @Override
    public void deleteCreditReportLoanOverdue(Long id) {

        // 删除
        creditReportLoanOverdueMapper.deleteById(id);
    }



    @Override
    public CreditReportLoanOverdueDO getCreditReportLoanOverdue(Long id) {
        return creditReportLoanOverdueMapper.selectById(id);
    }

    @Override
    public List<CreditReportLoanOverdueDO> getCreditReportLoanOverdueByDetailsId(Long creditReportDetailsId) {
        LambdaQueryWrapper<CreditReportLoanOverdueDO> queryWrapper = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<CreditReportLoanOverdueDO> eq = queryWrapper.eq(CreditReportLoanOverdueDO::getCreditReportDetailsId, creditReportDetailsId);
        return creditReportLoanOverdueMapper.selectList(eq);
    }
}
